package cz.fit.vutbr.pis2012.augeaswh.control.ekonom.stock_types;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import cz.fit.vutbr.pis2012.augeaswh.managers.StockTypesManager;
import cz.fit.vutbr.pis2012.augeaswh.persistence.StockType;

@ManagedBean
@ViewScoped
public class StockTypesConfirmDeleteDialogBean {
	@EJB
	private StockTypesManager sm;	
	private StockType stockType;
	
	public String getTitle() {
		return "Deleting stock type";
	}
	
	public String getQuestion() {
		if(this.stockType==null)
			return "";
		return "Are you sure you want to delete the stock type "+stockType.getName()+"?"; 
	}
	
	public void submit() {
		if(this.stockType!=null) {
			sm.delete(this.stockType);
			this.stockType=null;
		}
	}

	public StockType getStockType() {
		return stockType;
	}

	public void setStockType(StockType stockType) {
		this.stockType = stockType;
	}	
}
